package com.ruoyi.common.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class SessionFilter implements Filter {

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
            ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;

        // 头攻击检测
        String requestHost = request.getHeader("host");
        if (requestHost != null && checkBlankList(requestHost)) {
            response.setStatus(403);
            return;
        }

    }

private boolean checkBlankList(String host){
   if(host.contains("172.24.7.106")){
      return true;
   }
   return false;
}

}